<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="css/base.css" />
<link rel="stylesheet" href="css/StyleSheet.css" type="text/css" />
<script src="jquery/jquery-3.1.1.js"></script>
<script type="text/javascript">
	window.onload = function() {
		Index(); /* 跳转到首页 */
	};
	/* 跳转到首页 */
	function Index() {
		/*判断是否是会员登陆 */
		$.ajax({
			type : "POST",
			url : "Login!isLogin",
			success : function(msg) {
				if (msg == "ok") {
					//跳转到会员首页
					Post();
					$('.login').nextAll().show();
					autoHeight(2);
				} else {
					//跳转到匿名用户首页
					hidePost();
					$('.login').nextAll().hide();
					autoHeight(1);
				}
			},
			error : function(r, r2, err) {
				alert("连接错误:" + err.message);
			}
		});
	}
	/* 点击登录 */
	function login() {
		hidePost();
		window.open("login.jsp", "Iframe");
	}
	/* 点击退出 */
	function exit() {
		//实现异步请求
		$.ajax({
			type : "POST",
			url : "Login!exit",
			success : function(msg) {
				if (msg == "ok") {
					hidePost();
					$('.login').nextAll().hide();
					window.open("main.jsp", "Iframe");
				}
			},
			error : function(r, r2, err) {
				alert("连接错误:" + err.message);
			}
		});
	}
	/* 隐藏所有会员操作 */
	function hidePost() {
		$('.divMiddleEx').show();
		$('.divLeft').hide();
		$('.divMiddle').hide();
	}
	/* 显示所有会员操作 */
	function Post() {
		$('.divMiddleEx').hide();
		$('.divLeft').show();
		$('.divMiddle').show();
	}
	/* iframe宽高自适应 */
	function autoHeight(value) {
		var iframe;
		if (value == 1) {
			iframe = document.getElementById("Iframe");
		} else {
			iframe = document.getElementById("Iframe2");
		}
		if (iframe.Document) {
			iframe.height = iframe.Document.documentElement.scrollHeight;
		} else if (iframe.contentDocument) {
			iframe.height = iframe.contentDocument.body.offsetHeight;
		}
	}
</script>
</head>
<body class="bodyInit">
	<div id="divWrap">
		<!--顶部-->
		<iframe src="index_top.jsp" id="topIframe" name="topIframe"
			style="height: 270px; width: 100%;margin-bottom: 0;" scrolling="no"></iframe>
		<div>
			<div class="divContent">
				<div class="divheadPage">
					<a href="javascript:;" onclick="Index()"><img
						src="Images/newImg/home.gif" alt="回首页" />
					</a>
				</div>

				<!--(匿名用户)-->
				<div style="display: block;" class="divMiddleEx">
					<iframe id="Iframe" name="Iframe" src="main.jsp" width="100%"
						scrolling="no" onload="autoHeight(1)" style="min-height: 246px;"></iframe>
				</div>

				<!--(会员)-->
				<!--左侧-->
				<iframe style="display: none;" id="leftIframe" name="leftIframe"
					src="index_left.jsp" class="divLeft" scrolling="no"></iframe>
				<!--内容区-->
				<div style="display: none;" class="divMiddle">
					<iframe id="Iframe2" name="Iframe2" src="main.jsp" width="100%"
						scrolling="no" onload="autoHeight(2)" style="min-height: 246px;"></iframe>
				</div>

				<!--右侧-->
				<div class="divRight">
					<div class="divOther">
						<ul class="ullink">
							<li class="addTitle">
								<h2 id="linkImage">友情链接</h2></li>
							<li class="liLink"><a href="http://www.cnblog.com">博客中国</a>
							</li>
							<li class="liLink"><a href="http://www.sina.com">新浪博客</a></li>
							<li class="liLink"><a href="http://www.sohu.com">搜狐博客</a></li>
						</ul>
					</div>
					<div class="divOther">
						<ul class="ullink">
							<li class="addTitle">
								<h2>功能列表</h2></li>
							<li class="liLink login"><a href="javascript:;"
								target="Iframe" onclick="login()">登录</a></li>
							<li class="liLink"><a href="Admin/blogSetting.jsp"
								target="Iframe2" onclick="Post()">配置Blog</a></li>
							<li class="liLink"><a href="Admin/postEdit.jsp"
								target="Iframe2" onclick="Post()">发表文章</a></li>
							<li class="liLink"><a href="Admin/galleryManage.jsp"
								target="Iframe2" onclick="Post()">维护图片库</a></li>
							<li class="liLink"><a href="Admin/imagesUpLoad.jsp"
								target="Iframe2" onclick="Post()">上传图片</a></li>
							<li class="liLink"><a href="Admin/imagesView.jsp"
								target="Iframe2" onclick="Post()">浏览图片</a></li>
							<li class="liLink"><a href="javascript:;" onclick="exit()">退出</a>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<div class="divbottom"></div>
	</div>
</body>

</html>
